package com.wuwei.jy.utils;


import java.util.Date;

/**
 * Created by Administrator on 2017/6/7.
 */
public class AuthorUtil {

   static String desStr = "fdas;fjdlsaf4674569892-9650868hlkhfvbmncbdeiouh";


    /**
     * 生成用户签名
     *
     * @param uid
     * @return
     */
    public static  String createSign(String uid) {
        String s = DateUtil.getDateFormat(new Date(), "yyyy-MM-dd hh:mm:ss");
        String sign = String.format("%s_%s", uid, s);
        String pstr = CyptoUtils.encode(desStr, sign);
        return pstr;
    }

    public static SignItem getSignData(String sign) {
        try {

            String pstr = CyptoUtils.decode(desStr, sign);
            String[] ss = pstr.split("_");
            SignItem item = null;
            if (ss.length > 1) {
                item = new SignItem();
                item.setUid(ss[0]);
                item.setCreateDate(DateUtil.formatDate(ss[1], "yyyy-MM-dd hh:mm:ss"));
                return item;
            }
            return item;

        } catch (Exception ex) {

            return null;

        }


    }




}
